home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / docdemos / setlengthdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-09  |  503 b   |  18 lines

  1. program SetLengthDemo;
  2.  
  3. var
  4.   S : String (26);
  5.  
  6. begin
  7.   S := 'Hello, world!';
  8.   SetLength (S, Length ('Hello'));
  9.   WriteLn (S);                                           { 'Hello' }
  10.  
  11.   SetLength (S, 26);
  12.   WriteLn (S);                     { 'Hello, world!(%$xy"!#&~+(/]' }
  13.                              { undefined characters ^^^^^^^^^^^^^^ }
  14.  
  15.   SetLength (S, 42);       { The overflow is *not* (yet) detected. }
  16.   WriteLn (S);        { This might cause a runtime error or crash. }
  17. end.
  18.